library ieee;
use IEEE.STD_LOGIC_1164.all;
use ieee.numeric_std.all;

entity splitter is
  generic (N     :     integer := 32);
  port( data_in  : in  std_logic_vector (N-1 downto 0);
        control  : in  std_logic_vector (1 downto 0);
        data_out : out std_logic_vector (N-1 downto 0)
        );
end splitter;

architecture Behavioral of splitter is

begin

  process (data_in, control)
  begin
    case control is
      when "11"                            =>
        data_out(N-1 downto 0)  <= data_in(N-1 downto 0);
      when "10"                            =>
        data_out(N-1 downto 16) <= (others => '0');
        data_out(15 downto 0)   <= data_in(15 downto 0);
      when "01"                            =>
        data_out(N-1 downto 8)  <= (others => '0');
        data_out(7 downto 0)    <= data_in(7 downto 0);
      when others                          =>
        data_out                <= (others => '0');
    end case;
  end process;

end Behavioral;
